! function($) {
var themeZeroArts = {
sliderNovo: function(){
if ($("#slider-novo .swiper-container").length) {
var t = $("#slider-novo").data("config"),
a = $("#slider-novo .swiper-slide").length,
o = $ > 1 && {
clickable: !0,
el: "#slider-novo .swiper-pagination"
};
new Swiper("#slider-novo .swiper-container", {
preloadImages: !1,
effect: t.fade ? "fade" : "slide",
autoplay: {
delay: t.time,
disableOnInteraction: !1
},
navigation: {
nextEl: "#slider-novo .swiper-container .next",
prevEl: "#slider-novo .swiper-container .prev"
},
lazy: {
loadPrevNext: !0
},
pagination: o,
loop: a > 1
});
t.stop && $("#slider-novo").on({
mouseenter: function() {
this.swiper.autoplay.stop()
},
mouseleave: function() {
this.swiper.autoplay.start()
}
}, ".swiper-container")
}
},
ativaThumb: function(){
$(document).on('click', '.thumbs .item', function() {
$(".thumbs .item").removeClass("ativo");
$(this).addClass("ativo");
});
},
selecionaVariante: function(){
$('.cor_variacao.passo2 ul.lista_cor_variacao>li>div.cor_selecionada').each(function(i, obj) {
setTimeout(() => {
$(this).trigger("click");
}, "300");
});
$('.passo1 select#variation_first_select option:selected').each(function(i, obj) {
setTimeout(() => {
$(this).parent().trigger("change");
}, "300");
});
},
removeFotosThumbs: function(){
let totalThumbs = $('.slick-list.draggable > .slick-track > li').length;
setTimeout(function(){
if(totalThumbs > 5){
let semRepeticao = ((totalThumbs-5)/2)
$('.slick-list.draggable > .slick-track > li:nth-child(n+'+(semRepeticao+1)+')').remove();
}
}, 1520);
},
galeriaDeImagens: function(){
if($('#colFotos').length){
// Select the node that will be observed for mutations
const targetNode = document.getElementById('colFotos');
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// Use traditional 'for loops' for IE 11
$('.slick-list.draggable').each(function(i, obj) {
console.log("CARREGOU ITENS AQUI!");
themeZeroArts.removeFotosThumbs();
});
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
}
},
limpaGaleriaVariante: function(){
$(".galeriaVariante").html("");
},
exibeVariante: function(variantes){
themeZeroArts.limpaGaleriaVariante();
$(".galeria").hide();
$(".galeriaVariante").show();
//console.log(variantes);
var htmlGrande = "";
var htmlPequeno = "";
for (var i = 0; i < variantes.length; i++) {
//console.log(variantes[i]["https"]);
if (i == 0){
htmlGrande += "
";
htmlPequeno += "
";
}
htmlGrande += "
";
htmlPequeno += "
";
// VIDEO
if (i == 0 && $(".box-imagens").attr("data-youtube") && $(".box-imagens").attr("data-youtube") != "" ){
htmlGrande += "
";
htmlPequeno += "
";
}
if (i == (variantes.length - 1)){
htmlGrande += "
";
htmlPequeno += "
";
}
}
var htmlVariantes = htmlGrande+htmlPequeno;
$(".galeriaVariante").html(htmlVariantes);
galleryThumbs = new Swiper('.galeriaVariante .thumbs .swiper-container', {
spaceBetween: 15,
direction: 'vertical',
slidesPerView: 5,
watchSlidesVisibility: true,
navigation: {
nextEl: '.next',
prevEl: '.prev',
},
lazy: {
loadPrevNext: !0
},
freeMode: true,
watchSlidesProgress: true,
breakpoints:{
0:{
slidesPerView:2,
direction: 'horizontal'
},
240:{
slidesPerView:3,
direction: 'horizontal'
},
768:{
slidesPerView:4,
direction: 'horizontal'
},
992:{
slidesPerView:5,
direction: 'vertical',
spaceBetween: 10,
}
},
});
galleryGrande = new Swiper('.galeriaVariante .grande .swiper-container', {
spaceBetween: 15,
direction: 'horizontal',
slidesPerView: 1,
watchSlidesVisibility: true,
navigation: {
nextEl: '.next',
prevEl: '.prev',
},
lazy: {
loadPrevNext: !0
},
thumbs: {
swiper: galleryThumbs
}
});
var lazy = new LazyLoad({
elements_selector: ".lazyload"
});
themeZeroArts.ativaThumb();
},
escondeVariante: function(){
themeZeroArts.limpaGaleriaVariante();
$(".galeriaVariante").hide();
$(".galeria").show();
},
variacaopasso1Selecionada: function(){
$(document).on('click', '.passo1 .lista_radios li', function() {
console.log("entrou!");
var variantId = $(this).find("input[type=radio]").val();
console.log(variantId);
// Select the node that will be observed for mutations
const targetNode = document.getElementById('show_size_and_color_secondary_type');
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// look through all mutations that just occured
for(var i=0; i 0){
themeZeroArts.exibeVariante(response["Variant"]["VariantImage"]);
}else{
themeZeroArts.escondeVariante();
}
}).fail(function( jqXHR, status, errorThrown ){
var response = $.parseJSON( jqXHR.responseText );
console.log(response);
themeZeroArts.escondeVariante();
});
}else{
themeZeroArts.escondeVariante();
}
console.log("CARREGOU CAMPO QUANTIDADE AQUI!");
observer.disconnect();
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})
$(document).on('click', '.passo1 .lista_cor_variacao li', function() {
variantId = $(this).attr("data-id");
//console.log(variantId);
// Select the node that will be observed for mutations
const targetNode = document.getElementById('form_comprar');
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// look through all mutations that just occured
for(var i=0; i 0){
themeZeroArts.exibeVariante(response["Variant"]["VariantImage"]);
}else{
themeZeroArts.escondeVariante();
}
}).fail(function( jqXHR, status, errorThrown ){
var response = $.parseJSON( jqXHR.responseText );
console.log(response);
themeZeroArts.escondeVariante();
});
}else{
themeZeroArts.escondeVariante();
}
console.log("CARREGOU CAMPO QUANTIDADE AQUI!");
observer.disconnect();
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})
$(document).on('change', '.passo1 select#variation_first_select', function() {
variantId = $(this).val();
//console.log(variantId);
// Select the node that will be observed for mutations
const targetNode = document.getElementById('form_comprar');
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// look through all mutations that just occured
for(var i=0; i 0){
themeZeroArts.exibeVariante(response["Variant"]["VariantImage"]);
}else{
themeZeroArts.escondeVariante();
}
}).fail(function( jqXHR, status, errorThrown ){
var response = $.parseJSON( jqXHR.responseText );
console.log(response);
themeZeroArts.escondeVariante();
});
}else{
themeZeroArts.escondeVariante();
}
console.log("CARREGOU CAMPO QUANTIDADE AQUI!");
observer.disconnect();
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})
},
variacaoPasso2Selecionada: function(){
$(document).on('click', '.passo2 .lista_cor_variacao li', function() {
variantId = $(this).attr("data-id");
//console.log(variantId);
// Select the node that will be observed for mutations
const targetNode = document.getElementById('form_comprar');
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// look through all mutations that just occured
for(var i=0; i 0){
themeZeroArts.exibeVariante(response["Variant"]["VariantImage"]);
}else{
themeZeroArts.escondeVariante();
}
}).fail(function( jqXHR, status, errorThrown ){
var response = $.parseJSON( jqXHR.responseText );
console.log(response);
themeZeroArts.escondeVariante();
});
}else{
themeZeroArts.escondeVariante();
}
console.log("CARREGOU CAMPO QUANTIDADE AQUI!");
observer.disconnect();
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})
$(document).on('change', '.passo2 select#second_dropdown', function() {
variantId = $(this).val();
//console.log(variantId);
// Select the node that will be observed for mutations
const targetNode = document.getElementById('form_comprar');
// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };
// Callback function to execute when mutations are observed
const callback = function(mutationsList, observer) {
// look through all mutations that just occured
for(var i=0; i 0){
themeZeroArts.exibeVariante(response["Variant"]["VariantImage"]);
}else{
themeZeroArts.escondeVariante();
}
}).fail(function( jqXHR, status, errorThrown ){
var response = $.parseJSON( jqXHR.responseText );
console.log(response);
themeZeroArts.escondeVariante();
});
}else{
themeZeroArts.escondeVariante();
}
console.log("CARREGOU CAMPO QUANTIDADE AQUI!");
observer.disconnect();
}
}
}
};
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);
// Start observing the target node for configured mutations
observer.observe(targetNode, config);
})
},
carrosselGaleria: function(){
galleryThumbs = new Swiper('.galeria .thumbs .swiper-container', {
spaceBetween: 15,
direction: 'vertical',
slidesPerView: 5,
watchSlidesVisibility: true,
navigation: {
nextEl: '.next',
prevEl: '.prev',
},
breakpoints:{
0:{
slidesPerView:2,
direction: 'horizontal'
},
240:{
slidesPerView:3,
direction: 'horizontal'
},
768:{
slidesPerView:4,
direction: 'horizontal'
},
992:{
slidesPerView:5,
direction: 'vertical',
spaceBetween: 10,
}
},
});
galleryGrande = new Swiper('.galeria .grande .swiper-container', {
spaceBetween: 15,
direction: 'horizontal',
slidesPerView: 1,
watchSlidesVisibility: true,
navigation: {
nextEl: '.next',
prevEl: '.prev',
},
thumbs: {
swiper: galleryThumbs
}
});
var lazy = new LazyLoad({
elements_selector: ".lazyload"
});
themeZeroArts.ativaThumb();
},
clicaPrimeiroTab:function(){
if($(".tabs-content .tab-link-mobile.description-link-tab:first-child").length){
console.log("Primeira aba");
$('.tabs-content .tab-link-mobile.description-link-tab:first-child').each(function(i, obj) {
setTimeout(() => {
$(this).trigger("click");
}, "300");
});
}
},
cartPreviewFooter: function(){
$(document).on('click', '#doacoesEscolha .opcoes .doacao', function() {
$("#doacoesEscolha .opcoes .doacao").removeClass("ativo");
$(this).addClass("ativo");
});
// Função de callback que será chamada quando ocorrerem mudanças
function callback(mutationsList, observer) {
for (let mutation of mutationsList) {
if (mutation.type === 'childList') {
// Verifica se algum dos nós adicionados possui as classes ".modal.cart-preview"
for (let addedNode of mutation.addedNodes) {
if (addedNode.nodeType === Node.ELEMENT_NODE &&
addedNode.classList.contains('modal') &&
addedNode.classList.contains('cart-preview')) {
console.log('Um elemento com as classes ".modal.cart-preview" foi adicionado.');
if($(".modal.cart-preview .cart-preview-footer").length){
console.log("Renderiza opcoes");
$('.modal.cart-preview #doacoesEscolha').remove();
// Recorta o elemento #doacoesEscolha de onde ele estiver no documento
let doacoesEscolha = $('#doacoesEscolha').clone().removeClass("hidden");
// Adiciona o elemento recortado no início do .modal.cart-preview .cart-preview-footer
$('.modal.cart-preview .cart-preview-footer').after(doacoesEscolha);
}
}
}
}
}
}
// Configurações do observador
const config = {
attributes: true, // Observar atributos do nó alvo
childList: true, // Observar filhos do nó alvo
subtree: true // Observar toda a subárvore do nó alvo
};
// Adiciona um ouvinte de evento para o submit do formulário
$('#form_comprar').on('submit', function(event) {
// Impede o comportamento padrão do formulário, se necessário
event.preventDefault();
// Criação do observador com a função de callback
const observer = new MutationObserver(callback);
// Selecionar o elemento alvo
const targetNode = document.querySelector('div[data-module="render"][data-render="snippets/cart_preview"]');
// Verificar se o nó alvo existe
if (targetNode) {
// Iniciar o observador no nó alvo com as configurações definidas
observer.observe(targetNode, config);
}
});
},
doacoesAjuda: function(){
$(document).on('mouseover', '#doacoesEscolha .ajuda:not(.mobile)', function() {
$(this).parent().parent().find(".boxAjuda").css('display', 'block');
});
$(document).on('mouseout', '#doacoesEscolha .ajuda:not(.mobile)', function() {
$(this).parent().parent().find(".boxAjuda").css('display', 'none');
});
$(document).on('click', '#doacoesEscolha .ajuda.mobile', function() {
if($(this).parent().parent().find(".boxAjuda").hasClass("ativo")){
$(this).parent().parent().find(".boxAjuda").removeClass("ativo");
$(this).parent().parent().find(".ajudaWrap").removeClass("ativo");
removeClickListener();
}else{
$(this).parent().parent().find(".boxAjuda").addClass("ativo");
$(this).parent().parent().find(".ajudaWrap").addClass("ativo");
addClickListener();
}
});
$(document).on('click', '#doacoesEscolha .boxAjuda .closeAjuda', function() {
$('.modal.cart-preview #doacoesEscolha .boxAjuda').removeClass('ativo');
$('.modal.cart-preview #doacoesEscolha .ajudaWrap').removeClass('ativo');
removeClickListener();
});
function addClickListener() {
$(document).on('click.closeBoxAjuda', function(event) {
if (!$(event.target).closest('.modal.cart-preview #doacoesEscolha .boxAjuda').length) {
$('.modal.cart-preview #doacoesEscolha .boxAjuda').removeClass('ativo');
$('.modal.cart-preview #doacoesEscolha .ajudaWrap').removeClass('ativo');
removeClickListener();
}
});
}
function removeClickListener() {
$(document).off('click.closeBoxAjuda');
}
// Impede que o clique no prÃÂÃÂÃÂóprio elemento oculte a caixa
$('.modal.cart-preview #doacoesEscolha .boxAjuda').click(function(event) {
event.stopPropagation();
});
},
}
$(document).ready(function(){
if($('html').hasClass('page-home')){
themeZeroArts.sliderNovo();
}
if($('html').hasClass('page-product')){
themeZeroArts.selecionaVariante();
themeZeroArts.galeriaDeImagens();
themeZeroArts.variacaopasso1Selecionada();
themeZeroArts.variacaoPasso2Selecionada();
themeZeroArts.carrosselGaleria();
themeZeroArts.clicaPrimeiroTab();
themeZeroArts.cartPreviewFooter();
themeZeroArts.doacoesAjuda();
}
})
}(jQuery);